#import "BWShiftInspectorPane.h"
#import "BWDocumentUndo.h"
#import "BWStitchSelection.h"


@implementation BWShiftInspectorPane

- (id) init
{
    if (self = [super init]) {
        if (![NSBundle loadNibNamed: @"BWShiftInspectorPane"
                       owner: self]) {
            NSLog (@"could not load BWShiftInspectorPane.nib");
        }
    }

    return (self);

} // init

- (NSImage *) toolbarIcon
{
    NSImage *image;
    image = [NSImage imageNamed: @"shift-pane.tiff"];

    return (image);

} // toolbarIcon





// --------------------------------------------------
// UI Foobage

- (IBAction) shiftStitches: (id) sender
{
    int hDirection = 0;
    int vDirection = 0;

    int tag;
    tag = [sender tag];

    switch (tag) {
    case 0:
        vDirection = -1;
        break;
    case 1:
        hDirection = -1;
        break;
    case 2:
        hDirection = 1;
        break;
    case 3:
        vDirection = 1;
        break;
    }

    NSIndexSet *indexes;
    indexes = [[document selectedStitches] indexesForSelection];

    if ([indexes count] == 0) {
        indexes = nil;
    }

    [document shiftStitchesHorizontal: hDirection
              vertical: vDirection
              indexes: indexes];

} // shiftStitches


- (NSString *) paneName
{
    return (@"BWShiftInspectorPane");
} // name

@end // BWShiftInspectorPane

